<?php
require_once("config/db.php");
// start a php array which we will return as ajax to our javascript (eventually)
if (isset($_POST['survey_id'])) {
 	$con=mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
	// Check connection
	if (mysqli_connect_errno()) {
	  	echo "Failed to connect to MySQL: " . mysqli_connect_error();
	}

	$surveyId = $_POST['survey_id'];
	$jsonArray = array('status' => 'Closed');

	$sql = 'UPDATE survey SET status="Closed" WHERE survey_id='.$surveyId ;
	
	mysqli_query($con,$sql);
	mysqli_close($con);
	echo json_encode($jsonArray);	
}
else
{echo "There's no survey like that";}
?>
